<?php
/** require:
 *  __PHY_LIB
 */
require_once(__PHY_LIB . "/class/Item.class.php");

class aFunc extends Item {
/// definition and constructor ///
	function aFunc($id=0, $field="") {
		Query::Query();
		$this->cfgKeyField("id");
		$this->cfgAllField("id,func_ename,func_cname,group_cname,description,add_user_id,add_time");
		$this->cfgTable("adm_func");
		if ("" == $field || "*" == $field) {
			$this->cfgField($this->mAllField);
		}
		else {
			$this->cfgField($field);
		}
		if (0 < $id) {
			$this->cfgWhere($this->mKeyField . "=" . $id);
			$this->load();
		}
		else {
			$this->set($this->mKeyField, $id);
		}
	}

	function look($sName) {
		$this->cfgWhere("func_ename='".addslashes($sName)."'");
		$this->load();
		return $this->getID();
	}

	function invalid() {
		if (!preg_match('/^\S{1,127}$/', $this->get('func_ename'), $x)) {
			return 'func_ename';
		}
		if (!preg_match('/^.{1,127}$/', $this->get('func_cname'), $x)) {
			return 'func_cname';
		}
		if (!preg_match('/^.{1,127}$/', $this->get('group_cname'), $x)) {
			return 'group_cname';
		}
		if (!(0 < $this->get('add_user_id'))) {
			return 'add_user_id';
		}

		return false;
	}

} /// end class aFunc.

class aFuncList extends ItemList {
	/// definition and constructor ///
	function aFuncList($tablename=null) {
		ItemList::ItemList();
		$this->cfgClass("aFunc");
		$this->cfgKeyField("id");
		$this->cfgAllField("id,func_ename,func_cname,group_cname,description,add_user_id,add_time");
		$this->cfgTable(null == $tablename ? "adm_func" : $tablename);
	}

} /// end class aFuncList.
?>
